﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.WebApiTool
{
    class InputUtil
    {
        public static bool Load(Data.Settings settings)
        {
            if(!LoadIsCamelCasePropertyName(settings))
            {
                return false;
            }

            if (!LoadAuthenticationMode(settings))
            {
                return false;
            }
            return true;
        }
        private static bool LoadIsCamelCasePropertyName(Data.Settings settings)
        {
            Console.WriteLine("是否启用属性首字母小写?");
            Console.WriteLine("Y:启用");
            Console.WriteLine("N:不启用");
            string input = Console.ReadLine();
            if (string.Equals(input, "Y", StringComparison.CurrentCultureIgnoreCase))
            {
                settings.IsCamelCasePropertyName = true;
                return true;
            }
            else if (string.Equals(input, "N", StringComparison.CurrentCultureIgnoreCase))
            {
                settings.IsCamelCasePropertyName = false;
                return true;
            }
            else
            {
                Console.WriteLine("输入错误!");
                Console.WriteLine("输入任意键关闭...");
                return false;
            }
        }

        private static bool LoadAuthenticationMode(Data.Settings settings)
        {
            Console.WriteLine("选择认证模式?");
            Console.WriteLine("1:ASPXForm");
            Console.WriteLine("2:WebApi");
            string input = Console.ReadLine();
            if (string.Equals(input, "1", StringComparison.CurrentCultureIgnoreCase))
            {
                settings.AuthMode = Data.AuthMode.ASPXForm;
                return true;
            }
            else if (string.Equals(input, "2", StringComparison.CurrentCultureIgnoreCase))
            {
                settings.AuthMode = Data.AuthMode.WebApi;
                return true;
            }
            else
            {
                Console.WriteLine("输入错误!");
                Console.WriteLine("输入任意键关闭...");
                return false;
            }
        }
    }
}
